
package zerous.craft.entity;

import android.graphics.*;
import zerous.craft.*;
import zerous.craft.entity.Player.STATE;

public class Block
{
	private Bitmap bmp;
	private int id;
	public int px,py;
	public Canvas c;
	public Paint p;
	
	public Block(Bitmap bmp,int id)
	{
		this.bmp = bmp;
		this.id = id;
	}
	
	public void draw(Canvas c, Paint p,int x,int y)
	{
		this.px = x;
		this.py = y;
		this.c = c;
		this.p = p;
		c.drawBitmap(bmp,x,y,p);
		hit(x,y);
	}

	public void hit(int x,int y)
	{
		if(GameRenderer.player.scrY>=this.py-32&&GameRenderer.player.scrX+32>=this.px+1&&GameRenderer.player.scrX<this.px+32&&GameRenderer.player.scrY<=this.py)
		{
			GameRenderer.player.turnY = GameRenderer.scrH/2 - y+33;
			//GameRenderer.player.state = STATE.Idel;
			GameRenderer.player.isVoid = false;
		}
		
		/*if(GameRenderer.player.scrX>=this.px-32&&GameRenderer.player.scrY<this.py)
		{
			GameRenderer.player.state = STATE.Idel;
		}
		
		/*if(Utills.isHit(this.px,this.py,32,32,GameRenderer.player.scrX,GameRenderer.player.scrY,32,32))
		{
			GameRenderer.player.isVoid=false;
			GameRenderer.player.state = STATE.Idel;
		}*/
	}
	
	public void remove(int x,int y,int w,int h)
	{
		c.drawRect(x+w,y+h,x,y,p);
	}
}
